package tongcheng.com.tongcheng.widght;


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import tongcheng.com.tongcheng.R;


/**
 * @author youj
 * 自定义dialog
 */
public class MessageDialog extends Dialog {


    private ImageView mMessage_dialog_icon;
    private TextView mMessage_dialog_message;
    private TextView mMessage_dialog_title;
    private Button mMessage_dialog_ok;
    private final View mView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(mView);
        //initView();
        setCanceledOnTouchOutside(true);
    }

    private void initView() {
        mMessage_dialog_icon = mView.findViewById(R.id.message_dialog_icon);
        mMessage_dialog_message = mView.findViewById(R.id.message_dialog_message);
        mMessage_dialog_title = mView.findViewById(R.id.message_dialog_title);
        mMessage_dialog_ok = mView.findViewById(R.id.message_dialog_ok);
    }

    public MessageDialog(Context context) {
        super(context, R.style.ProgressDialog);

        mView = View.inflate(context, R.layout.message_dialog_view, null);
        initView();
    }

    //设置点击事件
    public MessageDialog setOkClick(View.OnClickListener lisner) {
        mMessage_dialog_ok.setOnClickListener(lisner);
        return this;
    }
    //设置标题
    public MessageDialog setTitle(String title) {
        mMessage_dialog_title.setText(title);
        return this;
    }
    //设置要展示的信息
    public MessageDialog setMessage(String message) {
        mMessage_dialog_message.setText(message);
        return this;
    }
    //设置icon
    public MessageDialog setIcon( int resid) {
        mMessage_dialog_icon.setImageResource(resid);
        return this;
    }


    public MessageDialog showit() {
        show();
        return this;
    }





}
